﻿#include "EventFilter.h"
#include<QEvent>
EventFilter::EventFilter(std::function<bool(QEvent* ev)> fun, const int EventType, QObject* parent)
	:QObject(parent),
	m_fun(fun),
	m_EventType(EventType)
{
}

bool EventFilter::eventFilter(QObject* object, QEvent* ev)
{
    if(ev->type()== m_EventType)
		return m_fun(ev);   //返回true表示此事件已经处理了，不会继续传播
    return QObject::eventFilter(object, ev);
}
